module.exports = app => {
  // 解构赋值，获取需要的数据库的数据类型
  const { STRING, INTEGER, DOUBLE } = app.Sequelize;
  // 通过 app.model.define 方法建立数据表名，字段及数据类型
  const Order = app.model.define('order', {
    order_number: STRING,
    order_price: DOUBLE,
    order_isPay: INTEGER,
    order_userName: STRING,
    order_userTel: STRING,
    order_address: STRING,
    order_isSend: INTEGER,
    user_id: INTEGER,
    order_isConfirm: INTEGER
  });
  Order.associate = function() {
    app.model.Order.belongsTo(app.model.Wxuser, {
      // 指定外键
      foreignKey: 'user_id',
      // 外键指向
      targetKey: 'id'
    });
  };
  return Order;
};
